import {
  q as n,
  p as D,
  ap as M,
  X as v,
  f as R,
  H as N,
  av as b,
  aw as O,
  az as T,
  as as s,
  aG as V,
  at as h
} from "./index-b50e6ef9.js";
import { f as W } from "./finance-81050a55.js";
function j(w) {
  const d = n([]),
    a = n(!0);
  n({}), D();
  const g = n(1),
    m = n({}),
    c = n(10),
    x = M("reload"),
    u = v({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    B = v({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    _ = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 80 },
      { label: "首单金额", prop: "first", minWidth: 100 },
      { label: "首单单数", prop: "first_num", minWidth: 60 },
      { label: "复购金额", prop: "fu", minWidth: 100 },
      { label: "复购单数", prop: "fu_num", minWidth: 80 },
      { label: "总金额", prop: "all", minWidth: 100 },
      { label: "总单数", prop: "all_num", minWidth: 80 },
      { label: "总拨比积分", prop: "income", minWidth: 100 },
      { label: "积分购买金额", prop: "wares_money", minWidth: 100 },
      { label: "现金购买金额", prop: "wares_ready", minWidth: 100 },
      { label: "创建时间", prop: "create_time", minWidth: 180 }
    ],
    C = R(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function S(e) {
    T(e);
  }
  async function I(e) {
    const o = { role_id: e.role_id },
      l = JSON.stringify(o),
      r = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(l)) },
      t = await V(r);
    t.code == 200
      ? (h("删除成功", { type: "success" }), x())
      : h(t.msg, { type: "error" });
  }
  function J() {}
  function z(e) {
    (c.value = e), p(void 0, e);
  }
  function U(e) {
    (g.value = e), p(e, void 0);
  }
  function k(e) {}
  function L(e) {
    (B.text = `正在加载第${e}页...`),
      (a.value = !0),
      b(600).then(() => {
        a.value = !1;
      });
  }
  async function y(e) {
    a.value = !0;
    const o = {
        page: 1,
        pagesize: c.value,
        content: "day",
        user_phone: e.user_phone,
        type: e.type
      },
      l = JSON.stringify(o),
      r = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(l)) },
      { data: t } = await W(r);
    (d.value = t.day.data),
      (u.total = t.day.total),
      setTimeout(() => {
        a.value = !1;
      }, 500);
  }
  async function p(e = g.value, o = c.value) {
    const f = JSON.stringify({ page: e, pagesize: o, content: "day" }),
      t = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(f)) },
      i = await W(t);
    i.code === 200
      ? ((m.value = i.data),
        (d.value = i.data.day.data),
        (u.total = i.data.day.total),
        setTimeout(() => {
          a.value = !1;
        }, 500))
      : h(i.msg, { type: "error" });
  }
  const A = e => {
    e && (e.resetFields(), y());
  };
  return (
    N(() => {
      b().then(() => {
        const { setWatermark: e } = O(w.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        p();
    }),
    {
      loading: a,
      columns: _,
      dataList: d,
      pagination: u,
      buttonClass: C,
      dataAll: m,
      onSearch: y,
      resetForm: A,
      handleaddUser: J,
      handleUpdate: S,
      handleDelete: I,
      handleSizeChange: z,
      handleCurrentChange: U,
      handleSelectionChange: k,
      onCurrentChange: L
    }
  );
}
export { j as useRole };
